package com.example.administrator.ygddriver.webview;

import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;

import com.baidu.mapframework.nirvana.annotation.Url;
import com.example.administrator.ygddriver.R;
import com.example.administrator.ygddriver.base.BaseActivity;
import com.example.administrator.ygddriver.tool.SimpleToolbar;

public class WebActivity extends BaseActivity {
    private WebView webView;
    private SimpleToolbar simpleToolbar;
    private String URl;

    @Override
    public int initLayout() {
        return R.layout.activity_web;
    }

    @Override
    public void initView() {
        webView = findViewById(R.id.activity_web_wv);
        simpleToolbar = findViewById(R.id.activity_web_stb);
    }

    @Override
    public void initDate() {
        setSimpleToolbar();
        URl = getIntent().getStringExtra("URL");
        webView.loadUrl(URl);
    }

    private void setSimpleToolbar() {
        simpleToolbar.setMainTitle("详细消息");
        simpleToolbar.setMainTitleColor("#000000");
        simpleToolbar.setBackIv(R.mipmap.left_title);
        simpleToolbar.setToolColor("#ffffff");
        simpleToolbar.setBackIvClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (webView != null) {
            webView.stopLoading();
            webView.clearHistory();
            webView.clearCache(true);
            webView.loadUrl("about:blank");
            webView.pauseTimers();
            webView = null;
        }
    }
}
